package com.inei.cenacom.view;

import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.inei.cenacom.R;
import com.inei.cenacom.controller.Cap100Controller;
import com.inei.cenacom.controller.Cap200Controller;
import com.inei.cenacom.controller.Cap300Controller;
import com.inei.cenacom.controller.Cap400Controller;
import com.inei.cenacom.controller.CaratulaController;
import com.inei.cenacom.controller.EntrevistaController;
import com.inei.cenacom.model.entity.Cap100;
import com.inei.cenacom.model.entity.Cap200;
import com.inei.cenacom.model.entity.Cap300;
import com.inei.cenacom.model.entity.Cap400;
import com.inei.cenacom.model.entity.Caratula;
import com.inei.cenacom.model.entity.Entrevista;

public class Cobertura_Activity extends Activity {

	private TextView tvA, tvB;

	// TextView seccion C = Cap 100
	TextView tvC_R_1, tvC_R_2, tvC_R_3, tvC_R_4, tvC_R_5, tvC_R_6, tvC_R_7,
			tvC_R_8, tvC_R_9, tvC_R_10, tvC_R_11, tvC_R_12, tvC_I_1, tvC_I_2,
			tvC_I_3, tvC_I_4, tvC_I_5, tvC_I_6, tvC_I_7, tvC_I_8, tvC_I_9,
			tvC_I_10, tvC_I_11, tvC_I_12, tvC_F_1, tvC_F_2, tvC_F_3, tvC_F_4,
			tvC_F_5, tvC_F_6, tvC_F_7, tvC_F_8, tvC_F_9, tvC_F_10, tvC_F_11,
			tvC_F_12, tvC_C_1, tvC_C_2, tvC_C_3, tvC_C_4, tvC_C_5, tvC_C_6,
			tvC_C_7, tvC_C_8, tvC_C_9, tvC_C_10, tvC_C_11, tvC_C_12, tvD_R_1,
			tvD_R_2, tvD_R_3, tvD_R_4, tvD_R_5, tvD_R_6, tvD_R_7, tvD_R_8,
			tvD_R_9, tvD_R_10, tvD_R_11, tvD_R_12, tvD_R_13, tvD_R_14,
			tvD_R_15, tvD_R_16, tvD_R_17, tvD_R_18, tvD_R_19, tvD_R_20,
			tvD_R_21, tvD_R_22, tvD_I_1, tvD_I_2, tvD_I_3, tvD_I_4, tvD_I_5,
			tvD_I_6, tvD_I_7, tvD_I_8, tvD_I_9, tvD_I_10, tvD_I_11, tvD_I_12,
			tvD_I_13, tvD_I_14, tvD_I_15, tvD_I_16, tvD_I_17, tvD_I_18,
			tvD_I_19, tvD_I_20, tvD_I_21, tvD_I_22, tvD_F_1, tvD_F_2, tvD_F_3,
			tvD_F_4, tvD_F_5, tvD_F_6, tvD_F_7, tvD_F_8, tvD_F_9, tvD_F_10,
			tvD_F_11, tvD_F_12, tvD_F_13, tvD_F_14, tvD_F_15, tvD_F_16,
			tvD_F_17, tvD_F_18, tvD_F_19, tvD_F_20, tvD_F_21, tvD_F_22,
			tvD_C_1, tvD_C_2, tvD_C_3, tvD_C_4, tvD_C_5, tvD_C_6, tvD_C_7,
			tvD_C_8, tvD_C_9, tvD_C_10, tvD_C_11, tvD_C_12, tvD_C_13, tvD_C_14,
			tvD_C_15, tvD_C_16, tvD_C_17, tvD_C_18, tvD_C_19, tvD_C_20,
			tvD_C_21, tvD_C_22, tvE_R_1, tvE_R_2, tvE_R_3, tvE_R_4, tvE_R_5,
			tvE_R_6, tvE_R_7, tvE_R_8, tvE_R_9, tvE_R_10, tvE_R_11, tvE_R_12,
			tvE_R_13, tvE_R_14, tvE_R_15, tvE_I_1, tvE_I_2, tvE_I_3, tvE_I_4,
			tvE_I_5, tvE_I_6, tvE_I_7, tvE_I_8, tvE_I_9, tvE_I_10, tvE_I_11,
			tvE_I_12, tvE_I_13, tvE_I_14, tvE_I_15, tvE_F_1, tvE_F_2, tvE_F_3,
			tvE_F_4, tvE_F_5, tvE_F_6, tvE_F_7, tvE_F_8, tvE_F_9, tvE_F_10,
			tvE_F_11, tvE_F_12, tvE_F_13, tvE_F_14, tvE_F_15, tvE_C_1, tvE_C_2,
			tvE_C_3, tvE_C_4, tvE_C_5, tvE_C_6, tvE_C_7, tvE_C_8, tvE_C_9,
			tvE_C_10, tvE_C_11, tvE_C_12, tvE_C_13, tvE_C_14, tvE_C_15;

	private String ID_N;
	private int ANIO;
public TextView tvTitulo,tvDependencia;
	private CaratulaController cCon;
	private Caratula c;
	private EntrevistaController eCon;
	private List<Entrevista> lEnt;
	private Cap100Controller con100;
	private Cap100 c100;
	private Cap200Controller con200;
	private List<Cap200> l200;
	private Cap300Controller con300;
	private List<Cap300> l300;
	private Cap400Controller con400;
	private List<Cap400> l400;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_seguimiento);
		iniciarComponentes();
		cargarDatos();
	}

	private void iniciarComponentes() {
		ID_N = getIntent().getExtras().getString("ID_N");
		ANIO = getIntent().getExtras().getInt("ANIO");
		tvTitulo = (TextView)findViewById(R.id.tvTitulo);
		tvTitulo.setText(tvTitulo.getText().toString().replace("2014", ""+ANIO ));
		tvDependencia = (TextView)findViewById(R.id.tvDependencia);
		tvDependencia.setText("Dependencia Nro. "+ID_N);
		cCon = new CaratulaController(this);
		eCon = new EntrevistaController(this);
		con100 = new Cap100Controller(this);
		con200 = new Cap200Controller(this);
		con300 = new Cap300Controller(this);
		con400 = new Cap400Controller(this);

		tvA = (TextView) findViewById(R.id.tvA);
		tvB = (TextView) findViewById(R.id.tvB);

		tvC_R_1 = (TextView) findViewById(R.id.tvC_R_1);
		tvC_R_2 = (TextView) findViewById(R.id.tvC_R_2);
		tvC_R_3 = (TextView) findViewById(R.id.tvC_R_3);
		tvC_R_4 = (TextView) findViewById(R.id.tvC_R_4);
		tvC_R_5 = (TextView) findViewById(R.id.tvC_R_5);
		tvC_R_6 = (TextView) findViewById(R.id.tvC_R_6);
		tvC_R_7 = (TextView) findViewById(R.id.tvC_R_7);
		tvC_R_8 = (TextView) findViewById(R.id.tvC_R_8);
		tvC_R_9 = (TextView) findViewById(R.id.tvC_R_9);
		tvC_R_10 = (TextView) findViewById(R.id.tvC_R_10);
		tvC_R_11 = (TextView) findViewById(R.id.tvC_R_11);
		tvC_R_12 = (TextView) findViewById(R.id.tvC_R_12);
		tvC_I_1 = (TextView) findViewById(R.id.tvC_I_1);
		tvC_I_2 = (TextView) findViewById(R.id.tvC_I_2);
		tvC_I_3 = (TextView) findViewById(R.id.tvC_I_3);
		tvC_I_4 = (TextView) findViewById(R.id.tvC_I_4);
		tvC_I_5 = (TextView) findViewById(R.id.tvC_I_5);
		tvC_I_6 = (TextView) findViewById(R.id.tvC_I_6);
		tvC_I_7 = (TextView) findViewById(R.id.tvC_I_7);
		tvC_I_8 = (TextView) findViewById(R.id.tvC_I_8);
		tvC_I_9 = (TextView) findViewById(R.id.tvC_I_9);
		tvC_I_10 = (TextView) findViewById(R.id.tvC_I_10);
		tvC_I_11 = (TextView) findViewById(R.id.tvC_I_11);
		tvC_I_12 = (TextView) findViewById(R.id.tvC_I_12);
		tvC_F_1 = (TextView) findViewById(R.id.tvC_F_1);
		tvC_F_2 = (TextView) findViewById(R.id.tvC_F_2);
		tvC_F_3 = (TextView) findViewById(R.id.tvC_F_3);
		tvC_F_4 = (TextView) findViewById(R.id.tvC_F_4);
		tvC_F_5 = (TextView) findViewById(R.id.tvC_F_5);
		tvC_F_6 = (TextView) findViewById(R.id.tvC_F_6);
		tvC_F_7 = (TextView) findViewById(R.id.tvC_F_7);
		tvC_F_8 = (TextView) findViewById(R.id.tvC_F_8);
		tvC_F_9 = (TextView) findViewById(R.id.tvC_F_9);
		tvC_F_10 = (TextView) findViewById(R.id.tvC_F_10);
		tvC_F_11 = (TextView) findViewById(R.id.tvC_F_11);
		tvC_F_12 = (TextView) findViewById(R.id.tvC_F_12);
		tvC_C_1 = (TextView) findViewById(R.id.tvC_C_1);
		tvC_C_2 = (TextView) findViewById(R.id.tvC_C_2);
		tvC_C_3 = (TextView) findViewById(R.id.tvC_C_3);
		tvC_C_4 = (TextView) findViewById(R.id.tvC_C_4);
		tvC_C_5 = (TextView) findViewById(R.id.tvC_C_5);
		tvC_C_6 = (TextView) findViewById(R.id.tvC_C_6);
		tvC_C_7 = (TextView) findViewById(R.id.tvC_C_7);
		tvC_C_8 = (TextView) findViewById(R.id.tvC_C_8);
		tvC_C_9 = (TextView) findViewById(R.id.tvC_C_9);
		tvC_C_10 = (TextView) findViewById(R.id.tvC_C_10);
		tvC_C_11 = (TextView) findViewById(R.id.tvC_C_11);
		tvC_C_12 = (TextView) findViewById(R.id.tvC_C_12);

		tvD_R_1 = (TextView) findViewById(R.id.tvD_R_1);
		tvD_R_2 = (TextView) findViewById(R.id.tvD_R_2);
		tvD_R_3 = (TextView) findViewById(R.id.tvD_R_3);
		tvD_R_4 = (TextView) findViewById(R.id.tvD_R_4);
		tvD_R_5 = (TextView) findViewById(R.id.tvD_R_5);
		tvD_R_6 = (TextView) findViewById(R.id.tvD_R_6);
		tvD_R_7 = (TextView) findViewById(R.id.tvD_R_7);
		tvD_R_8 = (TextView) findViewById(R.id.tvD_R_8);
		tvD_R_9 = (TextView) findViewById(R.id.tvD_R_9);
		tvD_R_10 = (TextView) findViewById(R.id.tvD_R_10);
		tvD_R_11 = (TextView) findViewById(R.id.tvD_R_11);
		tvD_R_12 = (TextView) findViewById(R.id.tvD_R_12);
		tvD_R_13 = (TextView) findViewById(R.id.tvD_R_13);
		tvD_R_14 = (TextView) findViewById(R.id.tvD_R_14);
		tvD_R_15 = (TextView) findViewById(R.id.tvD_R_15);
		tvD_R_16 = (TextView) findViewById(R.id.tvD_R_16);
		tvD_R_17 = (TextView) findViewById(R.id.tvD_R_17);
		tvD_R_18 = (TextView) findViewById(R.id.tvD_R_18);
		tvD_R_19 = (TextView) findViewById(R.id.tvD_R_19);
		tvD_R_20 = (TextView) findViewById(R.id.tvD_R_20);
		tvD_R_21 = (TextView) findViewById(R.id.tvD_R_21);
		tvD_R_22 = (TextView) findViewById(R.id.tvD_R_22);
		tvD_I_1 = (TextView) findViewById(R.id.tvD_I_1);
		tvD_I_2 = (TextView) findViewById(R.id.tvD_I_2);
		tvD_I_3 = (TextView) findViewById(R.id.tvD_I_3);
		tvD_I_4 = (TextView) findViewById(R.id.tvD_I_4);
		tvD_I_5 = (TextView) findViewById(R.id.tvD_I_5);
		tvD_I_6 = (TextView) findViewById(R.id.tvD_I_6);
		tvD_I_7 = (TextView) findViewById(R.id.tvD_I_7);
		tvD_I_8 = (TextView) findViewById(R.id.tvD_I_8);
		tvD_I_9 = (TextView) findViewById(R.id.tvD_I_9);
		tvD_I_10 = (TextView) findViewById(R.id.tvD_I_10);
		tvD_I_11 = (TextView) findViewById(R.id.tvD_I_11);
		tvD_I_12 = (TextView) findViewById(R.id.tvD_I_12);
		tvD_I_13 = (TextView) findViewById(R.id.tvD_I_13);
		tvD_I_14 = (TextView) findViewById(R.id.tvD_I_14);
		tvD_I_15 = (TextView) findViewById(R.id.tvD_I_15);
		tvD_I_16 = (TextView) findViewById(R.id.tvD_I_16);
		tvD_I_17 = (TextView) findViewById(R.id.tvD_I_17);
		tvD_I_18 = (TextView) findViewById(R.id.tvD_I_18);
		tvD_I_19 = (TextView) findViewById(R.id.tvD_I_19);
		tvD_I_20 = (TextView) findViewById(R.id.tvD_I_20);
		tvD_I_21 = (TextView) findViewById(R.id.tvD_I_21);
		tvD_I_22 = (TextView) findViewById(R.id.tvD_I_22);
		tvD_F_1 = (TextView) findViewById(R.id.tvD_F_1);
		tvD_F_2 = (TextView) findViewById(R.id.tvD_F_2);
		tvD_F_3 = (TextView) findViewById(R.id.tvD_F_3);
		tvD_F_4 = (TextView) findViewById(R.id.tvD_F_4);
		tvD_F_5 = (TextView) findViewById(R.id.tvD_F_5);
		tvD_F_6 = (TextView) findViewById(R.id.tvD_F_6);
		tvD_F_7 = (TextView) findViewById(R.id.tvD_F_7);
		tvD_F_8 = (TextView) findViewById(R.id.tvD_F_8);
		tvD_F_9 = (TextView) findViewById(R.id.tvD_F_9);
		tvD_F_10 = (TextView) findViewById(R.id.tvD_F_10);
		tvD_F_11 = (TextView) findViewById(R.id.tvD_F_11);
		tvD_F_12 = (TextView) findViewById(R.id.tvD_F_12);
		tvD_F_13 = (TextView) findViewById(R.id.tvD_F_13);
		tvD_F_14 = (TextView) findViewById(R.id.tvD_F_14);
		tvD_F_15 = (TextView) findViewById(R.id.tvD_F_15);
		tvD_F_16 = (TextView) findViewById(R.id.tvD_F_16);
		tvD_F_17 = (TextView) findViewById(R.id.tvD_F_17);
		tvD_F_18 = (TextView) findViewById(R.id.tvD_F_18);
		tvD_F_19 = (TextView) findViewById(R.id.tvD_F_19);
		tvD_F_20 = (TextView) findViewById(R.id.tvD_F_20);
		tvD_F_21 = (TextView) findViewById(R.id.tvD_F_21);
		tvD_F_22 = (TextView) findViewById(R.id.tvD_F_22);
		tvD_C_1 = (TextView) findViewById(R.id.tvD_C_1);
		tvD_C_2 = (TextView) findViewById(R.id.tvD_C_2);
		tvD_C_3 = (TextView) findViewById(R.id.tvD_C_3);
		tvD_C_4 = (TextView) findViewById(R.id.tvD_C_4);
		tvD_C_5 = (TextView) findViewById(R.id.tvD_C_5);
		tvD_C_6 = (TextView) findViewById(R.id.tvD_C_6);
		tvD_C_7 = (TextView) findViewById(R.id.tvD_C_7);
		tvD_C_8 = (TextView) findViewById(R.id.tvD_C_8);
		tvD_C_9 = (TextView) findViewById(R.id.tvD_C_9);
		tvD_C_10 = (TextView) findViewById(R.id.tvD_C_10);
		tvD_C_11 = (TextView) findViewById(R.id.tvD_C_11);
		tvD_C_12 = (TextView) findViewById(R.id.tvD_C_12);
		tvD_C_13 = (TextView) findViewById(R.id.tvD_C_13);
		tvD_C_14 = (TextView) findViewById(R.id.tvD_C_14);
		tvD_C_15 = (TextView) findViewById(R.id.tvD_C_15);
		tvD_C_16 = (TextView) findViewById(R.id.tvD_C_16);
		tvD_C_17 = (TextView) findViewById(R.id.tvD_C_17);
		tvD_C_18 = (TextView) findViewById(R.id.tvD_C_18);
		tvD_C_19 = (TextView) findViewById(R.id.tvD_C_19);
		tvD_C_20 = (TextView) findViewById(R.id.tvD_C_20);
		tvD_C_21 = (TextView) findViewById(R.id.tvD_C_21);
		tvD_C_22 = (TextView) findViewById(R.id.tvD_C_22);

		tvE_R_1 = (TextView) findViewById(R.id.tvE_R_1);
		tvE_R_2 = (TextView) findViewById(R.id.tvE_R_2);
		tvE_R_3 = (TextView) findViewById(R.id.tvE_R_3);
		tvE_R_4 = (TextView) findViewById(R.id.tvE_R_4);
		tvE_R_5 = (TextView) findViewById(R.id.tvE_R_5);
		tvE_R_6 = (TextView) findViewById(R.id.tvE_R_6);
		tvE_R_7 = (TextView) findViewById(R.id.tvE_R_7);
		tvE_R_8 = (TextView) findViewById(R.id.tvE_R_8);
		tvE_R_9 = (TextView) findViewById(R.id.tvE_R_9);
		tvE_R_10 = (TextView) findViewById(R.id.tvE_R_10);
		tvE_R_11 = (TextView) findViewById(R.id.tvE_R_11);
		tvE_R_12 = (TextView) findViewById(R.id.tvE_R_12);
		tvE_R_13 = (TextView) findViewById(R.id.tvE_R_13);
		tvE_R_14 = (TextView) findViewById(R.id.tvE_R_14);
		tvE_R_15 = (TextView) findViewById(R.id.tvE_R_15);
		tvE_I_1 = (TextView) findViewById(R.id.tvE_I_1);
		tvE_I_2 = (TextView) findViewById(R.id.tvE_I_2);
		tvE_I_3 = (TextView) findViewById(R.id.tvE_I_3);
		tvE_I_4 = (TextView) findViewById(R.id.tvE_I_4);
		tvE_I_5 = (TextView) findViewById(R.id.tvE_I_5);
		tvE_I_6 = (TextView) findViewById(R.id.tvE_I_6);
		tvE_I_7 = (TextView) findViewById(R.id.tvE_I_7);
		tvE_I_8 = (TextView) findViewById(R.id.tvE_I_8);
		tvE_I_9 = (TextView) findViewById(R.id.tvE_I_9);
		tvE_I_10 = (TextView) findViewById(R.id.tvE_I_10);
		tvE_I_11 = (TextView) findViewById(R.id.tvE_I_11);
		tvE_I_12 = (TextView) findViewById(R.id.tvE_I_12);
		tvE_I_13 = (TextView) findViewById(R.id.tvE_I_13);
		tvE_I_14 = (TextView) findViewById(R.id.tvE_I_14);
		tvE_I_15 = (TextView) findViewById(R.id.tvE_I_15);
		tvE_F_1 = (TextView) findViewById(R.id.tvE_F_1);
		tvE_F_2 = (TextView) findViewById(R.id.tvE_F_2);
		tvE_F_3 = (TextView) findViewById(R.id.tvE_F_3);
		tvE_F_4 = (TextView) findViewById(R.id.tvE_F_4);
		tvE_F_5 = (TextView) findViewById(R.id.tvE_F_5);
		tvE_F_6 = (TextView) findViewById(R.id.tvE_F_6);
		tvE_F_7 = (TextView) findViewById(R.id.tvE_F_7);
		tvE_F_8 = (TextView) findViewById(R.id.tvE_F_8);
		tvE_F_9 = (TextView) findViewById(R.id.tvE_F_9);
		tvE_F_10 = (TextView) findViewById(R.id.tvE_F_10);
		tvE_F_11 = (TextView) findViewById(R.id.tvE_F_11);
		tvE_F_12 = (TextView) findViewById(R.id.tvE_F_12);
		tvE_F_13 = (TextView) findViewById(R.id.tvE_F_13);
		tvE_F_14 = (TextView) findViewById(R.id.tvE_F_14);
		tvE_F_15 = (TextView) findViewById(R.id.tvE_F_15);
		tvE_C_1 = (TextView) findViewById(R.id.tvE_C_1);
		tvE_C_2 = (TextView) findViewById(R.id.tvE_C_2);
		tvE_C_3 = (TextView) findViewById(R.id.tvE_C_3);
		tvE_C_4 = (TextView) findViewById(R.id.tvE_C_4);
		tvE_C_5 = (TextView) findViewById(R.id.tvE_C_5);
		tvE_C_6 = (TextView) findViewById(R.id.tvE_C_6);
		tvE_C_7 = (TextView) findViewById(R.id.tvE_C_7);
		tvE_C_8 = (TextView) findViewById(R.id.tvE_C_8);
		tvE_C_9 = (TextView) findViewById(R.id.tvE_C_9);
		tvE_C_10 = (TextView) findViewById(R.id.tvE_C_10);
		tvE_C_11 = (TextView) findViewById(R.id.tvE_C_11);
		tvE_C_12 = (TextView) findViewById(R.id.tvE_C_12);
		tvE_C_13 = (TextView) findViewById(R.id.tvE_C_13);
		tvE_C_14 = (TextView) findViewById(R.id.tvE_C_14);
		tvE_C_15 = (TextView) findViewById(R.id.tvE_C_15);
	}

	private void cargarDatos() {
		c = new Caratula();
		c.setID_N(ID_N);
		c.setANIO(ANIO);
		c = cCon.buscar(c);
		if (c != null) {
			if (c.getIVRESFIN_02() != 0 && c.getIVRESFIN_02_O() != null) {
				tvA.setText(getResources().getStringArray(
						R.array.arrayResultado)[c.getIVRESFIN_02()]
						+ (c.getIVRESFIN_02_O().isEmpty() ? "" : " - "
								+ c.getIVRESFIN_02_O()));
			} else {
				vacio(tvA);
			}
		} else {
			vacio(tvA);
		}

		lEnt = eCon.EntrevistaObtenerTodo(ID_N, ANIO);
		if (lEnt != null) {
			Entrevista e = lEnt.get(lEnt.size() - 1);
			if (e.getIII2_5() != 0) {
				tvB.setText(getResources().getStringArray(
						R.array.arrayResultado)[e.getIII2_5()]);
			} else {
				vacio(tvB);
			}
		} else {
			vacio(tvB);
		}

		c100 = new Cap100();
		c100.setID_N(ID_N);
		c100.setANIO(ANIO);
		c100 = con100.buscar(c100);
		if (c100 != null) {
			tvC_R_1.setText("" + c100.getDN101_1_A());
			tvC_R_2.setText("" + c100.getDN101_1_B());
			tvC_R_3.setText("" + c100.getDN101_1_C());
			tvC_R_4.setText("" + c100.getDN101_1_D());
			tvC_R_5.setText("" + c100.getDN101_1_E());
			tvC_R_6.setText("" + c100.getDN101_1_F());
			tvC_R_7.setText("" + c100.getDN101_1_G());
			tvC_R_8.setText("" + c100.getDN101_2());
			tvC_R_9.setText("" + c100.getDN101_3());
			tvC_R_10.setText("" + c100.getDN101_4());
			tvC_R_11.setText("" + c100.getDN101_5());
			tvC_R_12.setText("" + c100.getDN101_6());
			int c101_1 = 0, c101_2 = 0, c101_3 = 0, c101_4 = 0, c101_5 = 0, c101_6 = 0, c101_7 = 0, c101_8 = 0, c101_9 = 0, c101_10 = 0, c101_11 = 0, c101_12 = 0;
			l200 = con200.leer(ID_N, ANIO);
			if (l200 != null) {
				for (Cap200 c200 : l200) {
					if (c200.getIH204() == 1) {
						c101_1++;
					} else if (c200.getIH204() == 2) {
						c101_2++;
					} else if (c200.getIH204() == 3) {
						c101_3++;
					} else if (c200.getIH204() == 4) {
						c101_4++;
					} else if (c200.getIH204() == 5) {
						c101_5++;
					} else if (c200.getIH204() == 6) {
						c101_6++;
					} else if (c200.getIH204() == 7) {
						c101_7++;
					} else if (c200.getIH204() == 8 || c200.getIH204() == 9) {
						c101_8++;
					} else if (c200.getIH204() == 10) {
						c101_9++;
					} else if (c200.getIH204() == 11) {
						c101_10++;
					} else if (c200.getIH204() == 12 || c200.getIH204() == 13
							|| c200.getIH204() == 14 || c200.getIH204() == 15) {
						c101_11++;
					} else if (c200.getIH204() == 16 || c200.getIH204() == 17
							|| c200.getIH204() == 18 || c200.getIH204() == 19
							|| c200.getIH204() == 20 || c200.getIH204() == 21
							|| c200.getIH204() == 22) {
						c101_12++;
					}
				}
			}

			tvC_I_1.setText("" + c101_1);
			tvC_I_2.setText("" + c101_2);
			tvC_I_3.setText("" + c101_3);
			tvC_I_4.setText("" + c101_4);
			tvC_I_5.setText("" + c101_5);
			tvC_I_6.setText("" + c101_6);
			tvC_I_7.setText("" + c101_7);
			tvC_I_8.setText("" + c101_8);
			tvC_I_9.setText("" + c101_9);
			tvC_I_10.setText("" + c101_10);
			tvC_I_11.setText("" + c101_11);
			tvC_I_12.setText("" + c101_12);

			tvC_F_1.setText("" + (c100.getDN101_1_A() - c101_1));
			tvC_F_2.setText("" + (c100.getDN101_1_B() - c101_2));
			tvC_F_3.setText("" + (c100.getDN101_1_C() - c101_3));
			tvC_F_4.setText("" + (c100.getDN101_1_D() - c101_4));
			tvC_F_5.setText("" + (c100.getDN101_1_E() - c101_5));
			tvC_F_6.setText("" + (c100.getDN101_1_F() - c101_6));
			tvC_F_7.setText("" + (c100.getDN101_1_G() - c101_7));
			tvC_F_8.setText("" + (c100.getDN101_2() - c101_8));
			tvC_F_9.setText("" + (c100.getDN101_3() - c101_9));
			tvC_F_10.setText("" + (c100.getDN101_4() - c101_10));
			tvC_F_11.setText("" + (c100.getDN101_5() - c101_11));
			tvC_F_12.setText("" + (c100.getDN101_6() - c101_12));

			condicionC(tvC_C_1, c100.getDN101_1_A(), c101_1);
			condicionC(tvC_C_2, c100.getDN101_1_B(), c101_2);
			condicionC(tvC_C_3, c100.getDN101_1_C(), c101_3);
			condicionC(tvC_C_4, c100.getDN101_1_D(), c101_4);
			condicionC(tvC_C_5, c100.getDN101_1_E(), c101_5);
			condicionC(tvC_C_6, c100.getDN101_1_F(), c101_6);
			condicionC(tvC_C_7, c100.getDN101_1_G(), c101_7);
			condicionC(tvC_C_8, c100.getDN101_2(), c101_8);
			condicionC(tvC_C_9, c100.getDN101_3(), c101_9);
			condicionC(tvC_C_10, c100.getDN101_4(), c101_10);
			condicionC(tvC_C_11, c100.getDN101_5(), c101_11);
			condicionC(tvC_C_12, c100.getDN101_6(), c101_12);

			cargarD();
			cargarE();

		} else {
			vacio(tvC_R_1, tvC_R_2, tvC_R_3, tvC_R_4, tvC_R_5, tvC_R_6,
					tvC_R_7, tvC_R_8, tvC_R_9, tvC_R_10, tvC_R_11, tvC_R_12,
					tvC_I_1, tvC_I_2, tvC_I_3, tvC_I_4, tvC_I_5, tvC_I_6,
					tvC_I_7, tvC_I_8, tvC_I_9, tvC_I_10, tvC_I_11, tvC_I_12,
					tvC_F_1, tvC_F_2, tvC_F_3, tvC_F_4, tvC_F_5, tvC_F_6,
					tvC_F_7, tvC_F_8, tvC_F_9, tvC_F_10, tvC_F_11, tvC_F_12,
					tvC_C_1, tvC_C_2, tvC_C_3, tvC_C_4, tvC_C_5, tvC_C_6,
					tvC_C_7, tvC_C_8, tvC_C_9, tvC_C_10, tvC_C_11, tvC_C_12,
					tvD_R_1, tvD_R_2, tvD_R_3, tvD_R_4, tvD_R_5, tvD_R_6,
					tvD_R_7, tvD_R_8, tvD_R_9, tvD_R_10, tvD_R_11, tvD_R_12,
					tvD_R_13, tvD_R_14, tvD_R_15, tvD_R_16, tvD_R_17, tvD_R_18,
					tvD_R_19, tvD_R_20, tvD_R_21, tvD_R_22, tvD_I_1, tvD_I_2,
					tvD_I_3, tvD_I_4, tvD_I_5, tvD_I_6, tvD_I_7, tvD_I_8,
					tvD_I_9, tvD_I_10, tvD_I_11, tvD_I_12, tvD_I_13, tvD_I_14,
					tvD_I_15, tvD_I_16, tvD_I_17, tvD_I_18, tvD_I_19, tvD_I_20,
					tvD_I_21, tvD_I_22, tvD_F_1, tvD_F_2, tvD_F_3, tvD_F_4,
					tvD_F_5, tvD_F_6, tvD_F_7, tvD_F_8, tvD_F_9, tvD_F_10,
					tvD_F_11, tvD_F_12, tvD_F_13, tvD_F_14, tvD_F_15, tvD_F_16,
					tvD_F_17, tvD_F_18, tvD_F_19, tvD_F_20, tvD_F_21, tvD_F_22,
					tvD_C_1, tvD_C_2, tvD_C_3, tvD_C_4, tvD_C_5, tvD_C_6,
					tvD_C_7, tvD_C_8, tvD_C_9, tvD_C_10, tvD_C_11, tvD_C_12,
					tvD_C_13, tvD_C_14, tvD_C_15, tvD_C_16, tvD_C_17, tvD_C_18,
					tvD_C_19, tvD_C_20, tvD_C_21, tvD_C_22, tvE_R_1, tvE_R_2,
					tvE_R_3, tvE_R_4, tvE_R_5, tvE_R_6, tvE_R_7, tvE_R_8,
					tvE_R_9, tvE_R_10, tvE_R_11, tvE_R_12, tvE_R_13, tvE_R_14,
					tvE_R_15, tvE_I_1, tvE_I_2, tvE_I_3, tvE_I_4, tvE_I_5,
					tvE_I_6, tvE_I_7, tvE_I_8, tvE_I_9, tvE_I_10, tvE_I_11,
					tvE_I_12, tvE_I_13, tvE_I_14, tvE_I_15, tvE_F_1, tvE_F_2,
					tvE_F_3, tvE_F_4, tvE_F_5, tvE_F_6, tvE_F_7, tvE_F_8,
					tvE_F_9, tvE_F_10, tvE_F_11, tvE_F_12, tvE_F_13, tvE_F_14,
					tvE_F_15, tvE_C_1, tvE_C_2, tvE_C_3, tvE_C_4, tvE_C_5,
					tvE_C_6, tvE_C_7, tvE_C_8, tvE_C_9, tvE_C_10, tvE_C_11,
					tvE_C_12, tvE_C_13, tvE_C_14, tvE_C_15);

		}
	}

	private void condicionC(TextView tv, int v1, int v2) {
		if (v1 > 0) {
			if ((v1 - v2) > 0) {
				tv.setText("Incompleta");
			} else {
				tv.setText("Completa");
			}
		} else {
			tv.setText("Omision");
		}
	}

	public int contarIngresoD(int delito) {
		l300 = con300.leer(ID_N, ANIO, delito);
		if (l300 != null) {
			return l300.size();
		} else {
			return 0;
		}
	}

	public int contarIngresoE(int delito) {
		l400 = con400.Cap400ObtenerXCap200(ID_N, ANIO, delito);
		if (l400 != null) {
			return l400.size();
		} else {
			return 0;
		}
	}

	private void cargarD() {
		if (l200 != null) {
			int r204_1 = 0, r204_2 = 0, r204_3 = 0, r204_4 = 0, r204_5 = 0, r204_6 = 0, r204_7 = 0, r204_8 = 0, r204_9 = 0, r204_10 = 0, r204_11 = 0, r204_12 = 0, r204_13 = 0, r204_14 = 0, r204_15 = 0, r204_16 = 0, r204_17 = 0, r204_18 = 0, r204_19 = 0, r204_20 = 0, r204_21 = 0, r204_22 = 0;
			int i204_1 = 0, i204_2 = 0, i204_3 = 0, i204_4 = 0, i204_5 = 0, i204_6 = 0, i204_7 = 0, i204_8 = 0, i204_9 = 0, i204_10 = 0, i204_11 = 0, i204_12 = 0, i204_13 = 0, i204_14 = 0, i204_15 = 0, i204_16 = 0, i204_17 = 0, i204_18 = 0, i204_19 = 0, i204_20 = 0, i204_21 = 0, i204_22 = 0;
			for (Cap200 c200 : l200) {
				if (c200.getIH204() == 1) {
					r204_1 += c200.getIH212();
					i204_1 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 2) {
					r204_2 += c200.getIH212();
					i204_2 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 3) {
					r204_3 += c200.getIH212();
					i204_3 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 4) {
					r204_4 += c200.getIH212();
					i204_4 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 5) {
					r204_5 += c200.getIH212();
					i204_5 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 6) {
					r204_6 += c200.getIH212();
					i204_6 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 7) {
					r204_7 += c200.getIH212();
					i204_7 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 8) {
					r204_8 += c200.getIH212();
					i204_8 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 9) {
					r204_9 += c200.getIH212();
					i204_9 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 10) {
					r204_10 += c200.getIH212();
					i204_10 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 11) {
					r204_11 += c200.getIH212();
					i204_11 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 12) {
					r204_12 += c200.getIH212();
					i204_12 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 13) {
					r204_13 += c200.getIH212();
					i204_13 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 14) {
					r204_14 += c200.getIH212();
					i204_14 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 15) {
					r204_15 += c200.getIH212();
					i204_15 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 16) {
					r204_16 += c200.getIH212();
					i204_16 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 17) {
					r204_17 += c200.getIH212();
					i204_17 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 18) {
					r204_18 += c200.getIH212();
					i204_18 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 19) {
					r204_19 += c200.getIH212();
					i204_19 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 20) {
					r204_20 += c200.getIH212();
					i204_20 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 21) {
					r204_21 += c200.getIH212();
					i204_21 += contarIngresoD(c200.getNRO_MREG());
				} else if (c200.getIH204() == 22) {
					r204_22 += c200.getIH212();
					i204_22 += contarIngresoD(c200.getNRO_MREG());
				}
			}

			cargarResultado(tvD_R_1, tvD_I_1, tvD_F_1, tvD_C_1, r204_1, i204_1);
			cargarResultado(tvD_R_2, tvD_I_2, tvD_F_2, tvD_C_2, r204_2, i204_2);
			cargarResultado(tvD_R_3, tvD_I_3, tvD_F_3, tvD_C_3, r204_3, i204_3);
			cargarResultado(tvD_R_4, tvD_I_4, tvD_F_4, tvD_C_4, r204_4, i204_4);
			cargarResultado(tvD_R_5, tvD_I_5, tvD_F_5, tvD_C_5, r204_5, i204_5);
			cargarResultado(tvD_R_6, tvD_I_6, tvD_F_6, tvD_C_6, r204_6, i204_6);
			cargarResultado(tvD_R_7, tvD_I_7, tvD_F_7, tvD_C_7, r204_7, i204_7);
			cargarResultado(tvD_R_8, tvD_I_8, tvD_F_8, tvD_C_8, r204_8, i204_8);
			cargarResultado(tvD_R_9, tvD_I_9, tvD_F_9, tvD_C_9, r204_9, i204_9);
			cargarResultado(tvD_R_10, tvD_I_10, tvD_F_10, tvD_C_10, r204_10,
					i204_10);
			cargarResultado(tvD_R_11, tvD_I_11, tvD_F_11, tvD_C_11, r204_11,
					i204_11);
			cargarResultado(tvD_R_12, tvD_I_12, tvD_F_12, tvD_C_12, r204_12,
					i204_12);
			cargarResultado(tvD_R_13, tvD_I_13, tvD_F_13, tvD_C_13, r204_13,
					i204_13);
			cargarResultado(tvD_R_14, tvD_I_14, tvD_F_14, tvD_C_14, r204_14,
					i204_14);
			cargarResultado(tvD_R_15, tvD_I_15, tvD_F_15, tvD_C_15, r204_15,
					i204_15);
			cargarResultado(tvD_R_16, tvD_I_16, tvD_F_16, tvD_C_16, r204_16,
					i204_16);
			cargarResultado(tvD_R_17, tvD_I_17, tvD_F_17, tvD_C_17, r204_17,
					i204_17);
			cargarResultado(tvD_R_18, tvD_I_18, tvD_F_18, tvD_C_18, r204_18,
					i204_18);
			cargarResultado(tvD_R_19, tvD_I_19, tvD_F_19, tvD_C_19, r204_19,
					i204_19);
			cargarResultado(tvD_R_20, tvD_I_20, tvD_F_20, tvD_C_20, r204_20,
					i204_20);
			cargarResultado(tvD_R_21, tvD_I_21, tvD_F_21, tvD_C_21, r204_21,
					i204_21);
			cargarResultado(tvD_R_22, tvD_I_22, tvD_F_22, tvD_C_22, r204_22,
					i204_22);
		} else {
			vacio(tvD_R_1, tvD_R_2, tvD_R_3, tvD_R_4, tvD_R_5, tvD_R_6,
					tvD_R_7, tvD_R_8, tvD_R_9, tvD_R_10, tvD_R_11, tvD_R_12,
					tvD_R_13, tvD_R_14, tvD_R_15, tvD_R_16, tvD_R_17, tvD_R_18,
					tvD_R_19, tvD_R_20, tvD_R_21, tvD_R_22, tvD_I_1, tvD_I_2,
					tvD_I_3, tvD_I_4, tvD_I_5, tvD_I_6, tvD_I_7, tvD_I_8,
					tvD_I_9, tvD_I_10, tvD_I_11, tvD_I_12, tvD_I_13, tvD_I_14,
					tvD_I_15, tvD_I_16, tvD_I_17, tvD_I_18, tvD_I_19, tvD_I_20,
					tvD_I_21, tvD_I_22, tvD_F_1, tvD_F_2, tvD_F_3, tvD_F_4,
					tvD_F_5, tvD_F_6, tvD_F_7, tvD_F_8, tvD_F_9, tvD_F_10,
					tvD_F_11, tvD_F_12, tvD_F_13, tvD_F_14, tvD_F_15, tvD_F_16,
					tvD_F_17, tvD_F_18, tvD_F_19, tvD_F_20, tvD_F_21, tvD_F_22,
					tvD_C_1, tvD_C_2, tvD_C_3, tvD_C_4, tvD_C_5, tvD_C_6,
					tvD_C_7, tvD_C_8, tvD_C_9, tvD_C_10, tvD_C_11, tvD_C_12,
					tvD_C_13, tvD_C_14, tvD_C_15, tvD_C_16, tvD_C_17, tvD_C_18,
					tvD_C_19, tvD_C_20, tvD_C_21, tvD_C_22);
		}
	}

	public void cargarResultado(TextView tv1, TextView tv2, TextView tv3,
			TextView tv4, int v1, int v2) {
		tv1.setText("" + v1);
		tv2.setText("" + v2);
		tv3.setText("" + (v1 - v2));
		condicionC(tv4, v1, v2);
	}

	private void cargarE() {
		if (l200 != null) {
			int r204_1 = 0, r204_2 = 0, r204_3 = 0, r204_4 = 0, r204_5 = 0, r204_6 = 0, r204_7 = 0, r204_8 = 0, r204_9 = 0, r204_10 = 0, r204_11 = 0, r204_12 = 0, r204_13 = 0, r204_14 = 0, r204_15 = 0;
			int i204_1 = 0, i204_2 = 0, i204_3 = 0, i204_4 = 0, i204_5 = 0, i204_6 = 0, i204_7 = 0, i204_8 = 0, i204_9 = 0, i204_10 = 0, i204_11 = 0, i204_12 = 0, i204_13 = 0, i204_14 = 0, i204_15 = 0;
			for (Cap200 c200 : l200) {
				if (c200.getIH204() == 1) {
					r204_1 += c200.getIH213();
					i204_1 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 2) {
					r204_2 += c200.getIH213();
					i204_2 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 3) {
					r204_3 += c200.getIH213();
					i204_3 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 4) {
					r204_4 += c200.getIH213();
					i204_4 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 5) {
					r204_5 += c200.getIH213();
					i204_5 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 6) {
					r204_6 += c200.getIH213();
					i204_6 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 7) {
					r204_7 += c200.getIH213();
					i204_7 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 8) {
					r204_8 += c200.getIH213();
					i204_8 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 9) {
					r204_9 += c200.getIH213();
					i204_9 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 10) {
					r204_10 += c200.getIH213();
					i204_10 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 11) {
					r204_11 += c200.getIH213();
					i204_11 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 12) {
					r204_12 += c200.getIH213();
					i204_12 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 13) {
					r204_13 += c200.getIH213();
					i204_13 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 14) {
					r204_14 += c200.getIH213();
					i204_14 += contarIngresoE(c200.getNRO_MREG());
				} else if (c200.getIH204() == 15) {
					r204_15 += c200.getIH213();
					i204_15 += contarIngresoE(c200.getNRO_MREG());
				}
			}

			cargarResultado(tvE_R_1, tvE_I_1, tvE_F_1, tvE_C_1, r204_1, i204_1);
			cargarResultado(tvE_R_2, tvE_I_2, tvE_F_2, tvE_C_2, r204_2, i204_2);
			cargarResultado(tvE_R_3, tvE_I_3, tvE_F_3, tvE_C_3, r204_3, i204_3);
			cargarResultado(tvE_R_4, tvE_I_4, tvE_F_4, tvE_C_4, r204_4, i204_4);
			cargarResultado(tvE_R_5, tvE_I_5, tvE_F_5, tvE_C_5, r204_5, i204_5);
			cargarResultado(tvE_R_6, tvE_I_6, tvE_F_6, tvE_C_6, r204_6, i204_6);
			cargarResultado(tvE_R_7, tvE_I_7, tvE_F_7, tvE_C_7, r204_7, i204_7);
			cargarResultado(tvE_R_8, tvE_I_8, tvE_F_8, tvE_C_8, r204_8, i204_8);
			cargarResultado(tvE_R_9, tvE_I_9, tvE_F_9, tvE_C_9, r204_9, i204_9);
			cargarResultado(tvE_R_10, tvE_I_10, tvE_F_10, tvE_C_10, r204_10,
					i204_10);
			cargarResultado(tvE_R_11, tvE_I_11, tvE_F_11, tvE_C_11, r204_11,
					i204_11);
			cargarResultado(tvE_R_12, tvE_I_12, tvE_F_12, tvE_C_12, r204_12,
					i204_12);
			cargarResultado(tvE_R_13, tvE_I_13, tvE_F_13, tvE_C_13, r204_13,
					i204_13);
			cargarResultado(tvE_R_14, tvE_I_14, tvE_F_14, tvE_C_14, r204_14,
					i204_14);
			cargarResultado(tvE_R_15, tvE_I_15, tvE_F_15, tvE_C_15, r204_15,
					i204_15);
		} else {
			vacio(tvE_R_1, tvE_R_2, tvE_R_3, tvE_R_4, tvE_R_5, tvE_R_6,
					tvE_R_7, tvE_R_8, tvE_R_9, tvE_R_10, tvE_R_11, tvE_R_12,
					tvE_R_13, tvE_R_14, tvE_R_15, tvE_I_1, tvE_I_2, tvE_I_3,
					tvE_I_4, tvE_I_5, tvE_I_6, tvE_I_7, tvE_I_8, tvE_I_9,
					tvE_I_10, tvE_I_11, tvE_I_12, tvE_I_13, tvE_I_14, tvE_I_15,
					tvE_F_1, tvE_F_2, tvE_F_3, tvE_F_4, tvE_F_5, tvE_F_6,
					tvE_F_7, tvE_F_8, tvE_F_9, tvE_F_10, tvE_F_11, tvE_F_12,
					tvE_F_13, tvE_F_14, tvE_F_15, tvE_C_1, tvE_C_2, tvE_C_3,
					tvE_C_4, tvE_C_5, tvE_C_6, tvE_C_7, tvE_C_8, tvE_C_9,
					tvE_C_10, tvE_C_11, tvE_C_12, tvE_C_13, tvE_C_14, tvE_C_15);
		}
	}

	private void vacio(TextView... tv) {
		for (int i = 0; i < tv.length; i++) {
			tv[i].setText(" - ");
		}
	}

	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub

		Intent irMarco = new Intent(this, Marco_Activity.class);
		irMarco.putExtras(getIntent().getExtras());
		startActivity(irMarco);
		finish();
	}
}
